﻿using Model.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SYT.AliApiHandle;
using SYT.Web.liberty;
using Newtonsoft.Json;
using Model;
using Data.Service;

namespace SYT.Web.Controllers
{
    public class ProductController : MasterPage
    {
        //产品操作主页
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Index1()
        {
            return View();
        }

        public string RequestProList()
        { 
            string txtSearch = Request["txtSearch"];
            string qualityLevel = Request["qualityLevel"];
            string category = Request["category"];
            string gmtModifiedBegin = Request["gmtModifiedBegin"];
            string gmtModifiedEnd = Request["gmtModifiedEnd"];
            string PageIndex = Request["PageIndex"];

            string Currentcount = "0";
           
            //根据搜索条件请求数据
            Users user = JsonConvert.DeserializeObject<Users>(Session["UserreAllInfo"].ToString());

            List<ProductModel> products = GetApiShopInfo.GetProlist(PageIndex, txtSearch, qualityLevel, category, gmtModifiedBegin, gmtModifiedEnd, out Currentcount, user.memberId);
            //当前请求产品的总条数
            ViewBag.Currentcount = Currentcount;
            // 返回json格式的产品对象集合
            var dataInfo = new { Currentcount = Currentcount, products = products };
            return JsonConvert.SerializeObject(dataInfo);
        }

        
    }
}
